/*
 * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
 *
 * https://www.mall4j.com/
 *
 * 未经允许，不可做商业用途！
 *
 * 版权所有，侵权必究！
 */
package com.dlc.shop.delivery.multishop.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dlc.shop.common.response.ServerResponseEntity;
import com.dlc.shop.common.util.PageParam;
import com.dlc.shop.delivery.common.model.ChinaDeliveryOrderItem;
import com.dlc.shop.delivery.common.service.ChinaDeliveryOrderItemService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;


/**
 * 国内物流发货-订单物流项
 * @author liyong
 */
@RestController
@RequestMapping("/chinaDelivery/chinaDeliveryOrderItem")
//@Tag(name = "国内物流发货-订单物流项")
@AllArgsConstructor
public class ChinaDeliveryOrderItemController {

    private final ChinaDeliveryOrderItemService chinaDeliveryOrderItemService;

    @GetMapping("/page")
    @Operation(summary = "获取国内物流发货-订单物流项列表", description = "分页获取国内物流发货-订单物流项列表")
    public ServerResponseEntity<IPage<ChinaDeliveryOrderItem>> getChinaDeliveryOrderItemPage(PageParam<ChinaDeliveryOrderItem> page, ChinaDeliveryOrderItem chinaDeliveryOrderItem) {
        return ServerResponseEntity.success(chinaDeliveryOrderItemService.page(page, new LambdaQueryWrapper<ChinaDeliveryOrderItem>()));
    }

    @GetMapping("/info/{id}")
    @Operation(summary = "获取国内物流发货-订单物流项", description = "根据id获取国内物流发货-订单物流项")
    @Parameter(name = "id", description = "国内物流发货-订单物流项", required = true)
    public ServerResponseEntity<ChinaDeliveryOrderItem> getById(@PathVariable("id") Long id) {
        return ServerResponseEntity.success(chinaDeliveryOrderItemService.getById(id));
    }

    @PostMapping
    @PreAuthorize("@pms.hasPermission('chinaDelivery:chinaDeliveryOrderItem:save')")
    @Operation(summary = "保存国内物流发货-订单物流项", description = "保存国内物流发货-订单物流项")
    public ServerResponseEntity<Boolean> save(@RequestBody @Valid ChinaDeliveryOrderItem chinaDeliveryOrderItem) {
        return ServerResponseEntity.success(chinaDeliveryOrderItemService.save(chinaDeliveryOrderItem));
    }

    @PutMapping
    @PreAuthorize("@pms.hasPermission('chinaDelivery:chinaDeliveryOrderItem:update')")
    @Operation(summary = "更新国内物流发货-订单物流项", description = "更新国内物流发货-订单物流项")
    public ServerResponseEntity<Boolean> updateById(@RequestBody @Valid ChinaDeliveryOrderItem chinaDeliveryOrderItem) {
        return ServerResponseEntity.success(chinaDeliveryOrderItemService.updateById(chinaDeliveryOrderItem));
    }

    @DeleteMapping("/{id}")
    @PreAuthorize("@pms.hasPermission('chinaDelivery:chinaDeliveryOrderItem:delete')")
    @Operation(summary = "删除国内物流发货-订单物流项", description = "根据国内物流发货-订单物流项id删除国内物流发货-订单物流项")
    @Parameter(name = "id", description = "国内物流发货-订单物流项", required = true)
    public ServerResponseEntity<Boolean> removeById(@PathVariable Long id) {
        return ServerResponseEntity.success(chinaDeliveryOrderItemService.removeById(id));
    }
}
